package com.zpark.it.listener;

import com.zpark.it.service.CartService;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Title: CartRabbitMqListener
 * @Author Charles
 * @Package com.zpark.it.listener
 * @Date 2023/7/26 17:35
 */
@Component
public class CartRabbitMqListener {


    @Autowired
    private CartService cartService;


    @RabbitListener(
            bindings = @QueueBinding(
                    value = @Queue(name = "clear.queue"),
                    exchange = @Exchange(value = "topic.ex"),
                    key = "clear.cart"
            )
    )

    public void clear(List<Integer> cartIds){

        cartService.clearIds(cartIds);
    }
}
